package kr.nexmore.slmsample2.view.chartsample;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

import javax.annotation.PostConstruct;

import kr.nexmore.slmsample2.uri.Bundleclass_Uri;

import org.eclipse.birt.report.viewer.utilities.WebViewer;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.widgets.Composite;
import org.osgi.framework.Bundle;

public class GraphPart  {
	
	
	public GraphPart() {
	}

	/**
	 * Create contents of the view part.
	 */
	@PostConstruct
	public void createControls(Composite parent) {
		String path = "";
	    try {
	      Bundle bundle = Platform.getBundle(Bundleclass_Uri.PROJECT);
	      URL url = FileLocator.find(bundle, new Path("/src/kr/nexmore/slmsample2/report/graph.rptdesign"), null);
	      path = FileLocator.toFileURL(url).getPath();
	    } catch (MalformedURLException me) {
	      System.out.println("Fehler bei URL " + me.getStackTrace());
	    } catch (IOException e) {
	      e.printStackTrace();
	    }

	    Browser browser = new Browser(parent, SWT.NONE);
	    
	    // use the filename of your report
	    WebViewer.display(path, WebViewer.HTML, browser, "frameset");
	}

}
